<html>
<head><meta charset="utf-8"><title>How does error.emit() cause the compiler to stop? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html">How does error.emit() cause the compiler to stop?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209537292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/209537292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#209537292">(Sep 09 2020 at 16:50)</a>:</h4>
<p>I noticed here that this is a pretty hard error: <a href="https://github.com/rust-lang/rust/blob/b4bdc07ff5a70175dbcdff7331c557245ddb012f/compiler/rustc_ast_lowering/src/expr.rs#L596">https://github.com/rust-lang/rust/blob/b4bdc07ff5a70175dbcdff7331c557245ddb012f/compiler/rustc_ast_lowering/src/expr.rs#L596</a> that is emitted, but it doesn't seem to stop the flow of execution. How does this end up stopping the compiler after the lower_to_hir query? or does it not stop the compiler?</p>



<a name="209537509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/209537509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#209537509">(Sep 09 2020 at 16:52)</a>:</h4>
<p>It doesn't stop compilation. Only <code>fatal</code> errors stop compilation.</p>



<a name="209538002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/209538002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#209538002">(Sep 09 2020 at 16:56)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> interesting, so we believe in this case that an "acceptable" hir will be formed, we continue all analysis, and then eventually fail before codegen?</p>



<a name="209538141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/209538141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#209538141">(Sep 09 2020 at 16:57)</a>:</h4>
<p>Ah this is what I was looking for: <a href="https://github.com/rust-lang/rust/blob/b4bdc07ff5a70175dbcdff7331c557245ddb012f/compiler/rustc_interface/src/queries.rs#L276-L277">https://github.com/rust-lang/rust/blob/b4bdc07ff5a70175dbcdff7331c557245ddb012f/compiler/rustc_interface/src/queries.rs#L276-L277</a></p>



<a name="209538143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/209538143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#209538143">(Sep 09 2020 at 16:57)</a>:</h4>
<p>Yes. There are many places where we don't immediately stop compilation, but continue with a best effort guess and then only just before codegen stop.</p>



<a name="209538248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/209538248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#209538248">(Sep 09 2020 at 16:58)</a>:</h4>
<p>Thanks for the help!</p>



<a name="212319828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/212319828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#212319828">(Oct 05 2020 at 15:58)</a>:</h4>
<p>Somewhat related I think: what does a fatal error actually cause? In <a href="https://github.com/rust-lang/rust/issues/77487">#77487</a> I have removed some and I experience additional errors being emitted, but I expected the fatal errors not being hit, since the compiler finished. What semantics does FatalError.raise have?</p>



<a name="212320928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/212320928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#212320928">(Oct 05 2020 at 16:05)</a>:</h4>
<p>Fatal errors stop compilation by unwinding with a special panic payload, which is then caught somewhere in the driver</p>



<a name="212326688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/212326688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#212326688">(Oct 05 2020 at 16:52)</a>:</h4>
<p>So when I see the "compilation aborted due to N previous errors" message, that may or may not be the result of a fatal error call? Or is it somehow differentiated in the output?</p>



<a name="212327041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/212327041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#212327041">(Oct 05 2020 at 16:55)</a>:</h4>
<p>Not sure, I <em>think</em> we always use <code>FatalError</code> to abort compilation</p>



<a name="212327058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20error.emit%28%29%20cause%20the%20compiler%20to%20stop%3F/near/212327058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20error.2Eemit().20cause.20the.20compiler.20to.20stop.3F.html#212327058">(Oct 05 2020 at 16:55)</a>:</h4>
<p>Often via <code>abort_if_errors</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>